#ifndef GLOBALS_HEADER
#define GLOBALS_HEADER

#include "Box2D/Box2D.h"
#include "Sprite.h"
#include <string>

#include "glm/glm.hpp"

/*
 *  Globals.h
 *  Oblivion++
 *
 *  Created by Billy Clack on 8/6/12.
 *  Copyright 2012 __MyCompanyName__. All rights reserved.
 *
 */

//Which type of event is this.
enum EVENT_TYPE { INPUT_EVENT,
				  COLLISION_EVENT};

//These are the actions which the GameManager uses and responds to.
//Implement this in the 
//1) Mapping from key space to INPUT_EVENT_ACTION_T space.
//2) 
enum INPUT_EVENT_ACTION
{ 
	INPUT_MOVE_LEFT = 0, 
	INPUT_MOVE_RIGHT,
	INPUT_ZOOM_IN,
	INPUT_ZOOM_OUT,
	INPUT_SHOOT,
	INPUT_NONE
};

//These are collision events.
enum COLLISION_EVENT_ACTION
{
	//for a gun shot (essentially arrising from a ray case)
	COLLISION_EVENT_GUN_SHOT 
};


//Mouse button types
//Corresponds to GLFW's buttons
enum MOUSE_BUTTON{
	MOUSE_BUTTON_LEFT = 0,
	MOUSE_BUTTON_RIGTH = 1,
	MOUSE_BUTTON_NONE
};

struct MouseInfoRec {
	MouseInfoRec()
		: currbutt(MOUSE_BUTTON_NONE) {}

	glm::vec2 mWorldPos;
	glm::ivec2 mScreenPos;

	bool isPressed;
	MOUSE_BUTTON currbutt;
};

//
//Possible states which could be affecting the player
//Multiples of 2 for bit flags and multiple states.
#define PLAYER_STATE_NONE 0
#define	PLAYER_STATE_WALKING 1
#define PLAYER_STATE_SHOOTING 2

typedef int PLAYER_STATE_T;

#define PI 3.141592653589f

//Types of entities
enum ENTITY_TYPE
{
	ENTITY_PLAYER,
	ENTITY_GROUND,
	ENTITY_WEAPON,
	ENTITY_ITEM,
	ENTITY_PROJECTILE,
	
	ENTITY_NONE
};

enum ITEM_TYPE
{
	ITEM_TYPE_HEALTH,
	ITEM_TYPE_MAX_TYPES
};


enum WEAPON_TYPE {
	WEAPON_TYPE_GUN = 0, //for guns (instant type)
	WEAPON_TYPE_PROJECTILE, //for rockets, grenades, etc
	WEAPON_TYPE_NONE //fisticuffs :-)
};

//Properties for weapons
struct WeaponProperties {
	WeaponProperties () 
	{
		//The start weapon properties for players.
		mDamange = 1;
		mFireRate = 1;
		mName = "Test";
		mType = WEAPON_TYPE_GUN; //Is this nessesary...shoulding the class set this.

	}
	std::string mName; //Name of the weapon
	WEAPON_TYPE mType; //Type of the weapon
	float mDamange; //Damange per hit
	float mFireRate; //Firings per second
};

//Properties shared by all
struct PhysicsProperties {
	
	b2Vec2 mOrigin;
	
	float mDensity;
	float mFriction;
	float mElastic;
	bool mIsStatic;
	
	PhysicsProperties() :
	mDensity(1),
	mFriction(1),
	mElastic(0),
	mIsStatic(false),
	mOrigin(b2Vec2(0.0, 0.0) ){ }
};

//For raycasting
class RayCastCallback : public b2RayCastCallback {
public:
	RayCastCallback() {
		mFixture = NULL;
	}

	float32 ReportFixture( b2Fixture * fixture, const b2Vec2 & point,
							const b2Vec2 & normal, float32 fraction )
	{
		mFixture = fixture;
		mPoint = point;
		mNormal = normal;
		mFraction = fraction;

		printf("Collision at point: %f %f\n", point.x, point.y);

		return fraction;
	}

	b2Fixture * mFixture;
	b2Vec2 mPoint;
	b2Vec2 mNormal;
	float32 mFraction;
};

enum ANIMATED_SPRITE_TYPE { ONE_SHOT, REPEAT };

#endif